﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XYZCompiler
{
    class XYZMethod
    {
        public XYZMethod(XYZType owner,string name,XYZType returnType)
        {
            this.owner = owner;
            Name = name;
            ReturnType = returnType;
            _params.Add("this", owner);
        }

        public XYZType ReturnType { get; private set; }
        public string Name { get; private set; }
        public XYZType owner { get; private set; }
        public XYZType GetField(string name)
        {
            if (_localVars.ContainsKey(name)) //fisrt check local vars
                return _localVars[name];
            if (_params.ContainsKey(name))   //check params
                return _params[name];
            return owner.GetField(name);  //last check class members
        }
        public bool VeirfyField(string name)
        {
            if (_localVars.ContainsKey(name) || _params.ContainsKey(name))
                return false;
            return true;
        }
        public Dictionary<string, XYZType> _params = new Dictionary<string, XYZType>();
        public List<XYZType> _paramsList = new List<XYZType>();
        public Dictionary<string, XYZType> _localVars = new Dictionary<string, XYZType>(); 
        public Dictionary<string,VariableInfo>_variableInfo = new Dictionary<string, VariableInfo>(); 
    }
}
